	import {
		upload
	} from '@/utils/upload'

	import {
		editUserInfo
	} from '@/api/user'
export default 	function (_userInfo){
	async function uploadImg(e) {
			let {
				key
			} = await upload(e.target.files[0])
	
			let new_avatar = import.meta.env.VITE_IMG_URL + key
	
			_userInfo.value.avatar = new_avatar
			editUserInfo({
				avatar: new_avatar
			}).then(res => {
				uploadUserInfo.value({
					..._userInfo.value
				})
				console.log(res)
			})
		}
		return {
			uploadImg
		}
	
}